<template>
  <div class="car-footer">总价格：￥{{ totalPrice }}</div>
</template>

<script setup>
import mitts from "../bus";
let productList = ref([]);
mitts.on("giveProductList", (e) => {
  productList.value = e;
});
const totalPrice = computed(() => {
  const res = productList.value.reduce((sum, item) => {
    if (item.isSelected) {
      return sum + item.productPrice * item.productCount;
    } else {
      return sum;
    }
  }, 0);
  return res.toFixed(2);
});
</script>

<style lang="scss" scoped>
.car-footer {
  margin-top: 15px;
}
</style>
